package com.hu.zhcc.shiro.controller;


import com.hu.zhcc.shiro.entity.tj.TSportsItemLibrary;
import com.hu.zhcc.shiro.service.Tj_TSportsItemLibraryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 运动项目库 前端控制器
 * </p>
 *
 * @author tj
 * @since 2021-06-23
 */
@RestController
@RequestMapping("/tjtSportsItemLibrary")
public class TjTSportsItemLibraryController {
    @Autowired
    private Tj_TSportsItemLibraryService tjTSportsItemLibraryService;
    //查询所有
    @GetMapping("/all")
    public List<TSportsItemLibrary> queryAll(){
        System.out.println(tjTSportsItemLibraryService.queryAll());
        return tjTSportsItemLibraryService.queryAll();
    }
    //添加
    @PostMapping("")
    public int addLib(@RequestBody TSportsItemLibrary tSportsItemLibrary){
        System.out.println(tSportsItemLibrary);
        int insertlib = tjTSportsItemLibraryService.insertlib(tSportsItemLibrary);
        return insertlib;
    }
    //根据编号查询
    @GetMapping("/{id}")
    public TSportsItemLibrary queryById(@PathVariable("id")Integer id){
        TSportsItemLibrary tSportsItemLibrary = tjTSportsItemLibraryService.selectByPrimaryKey(id);
        return tSportsItemLibrary;
    }
    //修改
    @PutMapping("")
    public int updLib(@RequestBody TSportsItemLibrary tSportsItemLibrary){
      return   tjTSportsItemLibraryService.updateByPrimaryKey(tSportsItemLibrary);
    }


}

